package com.tjzd.learn;
import java.util.Scanner;
//质数：能被1和自身整除的整数叫质数，否则叫合数
public class primenumber {
    public static void main(String[] args) {
        System.out.println("请输入一个整数：");
        Scanner sc = new Scanner(System.in);
        int number = sc.nextInt();
        //标记思想，flag为true就为质数，为false就不为质数
        boolean flag=true;
        for(int i=2;i<number;i++)
        {
            if(number%i==0)
            {
                flag=false;
                break;
            }

        }
        if(flag)
        {
            System.out.println(number+"为质数");
        }
        else
        {
            System.out.println(number+"不为质数");
        }
    }
}
